package com.dsl.dslallinone.dto;

import com.fasterxml.jackson.annotation.JsonInclude;

import java.util.List;
import java.util.Map;

/**
 * DSL查询响应
 */
@JsonInclude(JsonInclude.Include.NON_NULL)
public class DslQueryResponse {
    private List<SeriesData> series;
    private TableData table;
    private MetaData meta;

    public DslQueryResponse() {}

    public DslQueryResponse(List<SeriesData> series, TableData table, MetaData meta) {
        this.series = series;
        this.table = table;
        this.meta = meta;
    }

    // Getters and Setters
    public List<SeriesData> getSeries() { return series; }
    public void setSeries(List<SeriesData> series) { this.series = series; }
    public TableData getTable() { return table; }
    public void setTable(TableData table) { this.table = table; }
    public MetaData getMeta() { return meta; }
    public void setMeta(MetaData meta) { this.meta = meta; }

    /**
     * 时间序列数据
     */
    public static class SeriesData {
        private String name;
        private List<Map<String, Object>> data;

        public SeriesData() {}

        public SeriesData(String name, List<Map<String, Object>> data) {
            this.name = name;
            this.data = data;
        }

        public String getName() { return name; }
        public void setName(String name) { this.name = name; }
        public List<Map<String, Object>> getData() { return data; }
        public void setData(List<Map<String, Object>> data) { this.data = data; }
    }

    /**
     * 表格数据
     */
    public static class TableData {
        private List<String> columns;
        private List<List<Object>> rows;

        public TableData() {}

        public TableData(List<String> columns, List<List<Object>> rows) {
            this.columns = columns;
            this.rows = rows;
        }

        public List<String> getColumns() { return columns; }
        public void setColumns(List<String> columns) { this.columns = columns; }
        public List<List<Object>> getRows() { return rows; }
        public void setRows(List<List<Object>> rows) { this.rows = rows; }
    }

    /**
     * 元数据
     */
    public static class MetaData {
        private Granularity granularity;
        private TimeWindow timeWindow;
        private String unit;
        private String dataSource;

        public MetaData() {}

        public MetaData(Granularity granularity, TimeWindow timeWindow, String unit, String dataSource) {
            this.granularity = granularity;
            this.timeWindow = timeWindow;
            this.unit = unit;
            this.dataSource = dataSource;
        }

        public Granularity getGranularity() { return granularity; }
        public void setGranularity(Granularity granularity) { this.granularity = granularity; }
        public TimeWindow getTimeWindow() { return timeWindow; }
        public void setTimeWindow(TimeWindow timeWindow) { this.timeWindow = timeWindow; }
        public String getUnit() { return unit; }
        public void setUnit(String unit) { this.unit = unit; }
        public String getDataSource() { return dataSource; }
        public void setDataSource(String dataSource) { this.dataSource = dataSource; }
    }
}
